package com.inspur.feign;

import com.inspur.demo.common.CommResultMsg;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//指定客户端名称
@FeignClient("spring-cloud-producer")
public interface FeignTestClient {

    //请注意如果 @PathVariable("id") 缺失会提示404错误
    @GetMapping("/feign/get/{id}")
    String get(@PathVariable("id") String id);

    @RequestMapping("/feign/getResult01/{id}")
    CommResultMsg getResult01(@PathVariable("id") String id);

    // 调用远程的post方法,如果参数为复杂对象,就算指定了method=RequestMethod.GET,依然会使用post方式请求
    // 远程的方法是get的时候就会失败，错误消息: feign.FeignException: status 405 reading FeignTestClient#getResult02(CommResultMsg)
    @RequestMapping(value = "/feign/getResult02", method = RequestMethod.GET)
    CommResultMsg getResult02(CommResultMsg comm);

    @GetMapping("/feign/list")
    List<CommResultMsg> list();

    @RequestMapping("/feign/postResult")
    public CommResultMsg postResult01(@RequestBody CommResultMsg comm);

    //@RequestBody标记可以省略
    @RequestMapping("/feign/postResult")
    CommResultMsg postResult02(CommResultMsg comm);


}
